package org.cainiao.algorithm.temp.niuke;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/**
 * <br />
 * <p>
 * Author: Cai Niao(wdhlzd@163.com)<br />
 */
public class HJ30 {

    // dec fab
    public static void main(String[] args) throws IOException {
        try (BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in))) {
            String line;
            while ((line = bufferedReader.readLine()) != null) {
                char[] chars = line.replace(" ", "").toCharArray();
                int length = chars.length;
                boolean isEven = length % 2 == 0;
                orderEven(chars, length, isEven);
                orderOdd(chars, length, isEven);
                transform(chars, length);
                System.out.println(chars);
            }
        }
    }

    private static void transform(char[] chars, int length) {
        for (int i = 0; i < length; i++) {
            char currentChar = chars[i];
            int value10 = -1;
            if (currentChar >= '0' && currentChar <= '9') {
                value10 = currentChar - '0';
            } else if (currentChar >= 'a' && currentChar <= 'f') {
                value10 = currentChar - 'a' + 10;
            } else if (currentChar >= 'A' && currentChar <= 'F') {
                value10 = currentChar - 'A' + 10;
            }
            if (value10 != -1) {
                int reversedValue10 = ((value10 & 8) >> 3) + ((value10 & 4) >> 1)
                    + ((value10 & 1) << 3) + ((value10 & 2) << 1);
                chars[i] = (char) (reversedValue10 > 9 ? ('A' + (reversedValue10 - 10)) : ('0' + reversedValue10));
            }
        }
    }

    private static void orderEven(char[] chars, int length, boolean isEven) {
        if (length < 3) {
            return;
        }
        order(chars, 0, isEven ? length - 2 : length - 1);
    }

    private static void orderOdd(char[] chars, int length, boolean isEven) {
        if (length < 4) {
            return;
        }
        order(chars, 1, isEven ? length - 1 : length - 2);
    }

    private static void order(char[] chars, int left, int right) {
        int length = right - left + 1;
        if (length <= 2) {
            return;
        }
        swap(chars, left + (int) (Math.random() * length / 2) * 2, right);
        int[] indexes = divide(chars, left, right);
        order(chars, left, indexes[0]);
        order(chars, indexes[1], right);
    }

    private static int[] divide(char[] chars, int left, int right) {
        int index = left;
        int lessBoundary = left - 2;
        int moreBoundary = right;
        char divideValue = chars[right];
        while (index < moreBoundary) {
            char currentChar = chars[index];
            if (currentChar < divideValue) {
                lessBoundary += 2;
                swap(chars, index, lessBoundary);
                index += 2;
            } else if (currentChar == divideValue) {
                index += 2;
            } else {
                moreBoundary -= 2;
                swap(chars, index, moreBoundary);
            }
        }
        swap(chars, moreBoundary, right);
        return new int[]{lessBoundary, moreBoundary};
    }

    private static void swap(char[] chars, int index1, int index2) {
        char temp = chars[index1];
        chars[index1] = chars[index2];
        chars[index2] = temp;
    }
}
